package com.zwxu.cas.web.authentication.principal;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.jasig.cas.authentication.Credential;
import org.jasig.cas.authentication.principal.Principal;
import org.jasig.cas.authentication.principal.PrincipalResolver;
import org.jasig.cas.authentication.principal.SimplePrincipal;


public class CasCredentialPrincipalResolver implements PrincipalResolver{

	@Override
	public Principal resolve(Credential credential) {
		 final CasCredential casCredential = (CasCredential) credential;

        Map<String, Object> attr = new HashMap<String, Object>();
        attr.put("LoginName", casCredential.getUsername());


        SimplePrincipal simplePrincipal = new SimplePrincipal(casCredential.getUsername(), attr);
        return simplePrincipal;
	}

	@Override
	public boolean supports(Credential credential) {
		// TODO Auto-generated method stub
		return true;
	}

}
